// my.js
Page({
  data: {
    isLoggedIn: false,
    username: ''
  },
  navigateToLogin() {
    wx.navigateTo({ url: '/pages/login/login' });
  },
  logout() {
    wx.removeStorageSync('token');
    this.setData({
      isLoggedIn: false,
      username: ''
    });
    wx.showToast({ title: '已退出登录', icon:'success' });
  },
  onLoad() {
    const token = wx.getStorageSync('token');
    if (token) {
      this.setData({
        isLoggedIn: true
      });
    }
  },
  onShow() {
    const token = wx.getStorageSync('token');
    if (token) {
      this.setData({
        isLoggedIn: true
      });
    } else {
      this.setData({
        isLoggedIn: false
      });
    }
  },
  myOneTapHandler(e) {
    wx.navigateTo({ url: '/pages/my/delivery-history/delivery-history' });
  },
  myTwoTapHandler(e) {
    wx.navigateTo({ url: '/pages/my/my-favorites/my-favorites' });
  },
  myThreeTapHandler(e) {
    wx.navigateTo({ url: '/pages/my/about-us/about-us' });
  }
});